<?php
/**
* @package Scribble
*/
use Buan\Config;
use Buan\UrlCommand;
?>

<div class="head">
	<h1>First Time Installation</h1>
</div>

<?php if(!empty($preSteps)): ?>
	<p>
		Before we get going, please follow the steps below to get your system ready for Scribble ...
	</p>
	<ol>
		<?php if(in_array("create-database", $preSteps)): ?>
			<li>
				<h3>Create a database</h3>
				<p>
					Scribble uses PHP's <a href="http://www.php.net/pdo" rel="external" title="PDO Extension">PDO extension</a> to interface with the database, so you may use any storage medium <a href="http://www.php.net/manual/en/pdo.drivers.php" rel="external" title="PDO supported drivers">supported by PDO</a>. Please refer to your chosen database's documentation for instructions on how to create a new database.
				</p>
				<p>
					Once you've created the database you must tell Scribble how to connect to it by supplying the appropriate settings in your application's configuration script, which is located in the following location:
				</p>
				<pre class="code"><?php $this->html->e(Config::get('app.configFile')); ?></pre>
				<p>
					Once you've applied the correct settings, <a href="<?php $this->html->eUrl(UrlCommand::createUrl('scribble', 'install')); ?>">refresh this page</a> to continue the installation process.
				</p>
			</li>
		<?php endif; ?>
	
		<?php if(in_array("setup-upload-path", $preSteps)): ?>
			<li>
				<h3>Specify a valid, writeable upload path</h3>
				<p>
					The upload path currently in use is either missing or Scribble cannot write to it (this is where all file-uploads are stored). Please check the write-permissions on the following folder before <a href="<?php $this->html->eUrl(UrlCommand::createUrl('scribble', 'install')); ?>">refreshing this page</a> and continuing installation:
				</p>
				<pre class="code"><?php $this->html->e(Config::get('ext.Scribble.uploads.dir')); ?></pre>
			</li>
		<?php endif; ?>
	
		<?php if(in_array("setup-data-dir", $preSteps)): ?>
			<li>
				<h3>The <code>data</code> folder is not writable</h3>
				<p>
					Scribble is unable to write to the following folder, so please check it's write-permissions before <a href="<?php $this->html->eUrl(UrlCommand::createUrl('scribble', 'install')); ?>">refreshing this page</a> and continuing installation:
				</p>
				<pre class="code"><?php $this->html->e(Config::get('ext.Scribble.dir.data')); ?></pre>
			</li>
		<?php endif; ?>
	</ol>

<?php else: ?>
	<p>
		It appears that everything is configured correctly so installation can go ahead!
	</p>
	<p>
		Please review the following details carefully before continuing with installation.
	</p>
	<p class="warning">
		<strong>DSN</strong>: <code><?php $this->html->e($dbInfo['dsn']); ?></code><br/>
		<strong>WARNING</strong>: All conflicting database tables will be overwritten so if you have any important content within them please <strong>backup now before proceeding</strong>.
	</p>
	<p class="information">
		<strong>Data folder:</strong> <code><?php $this->html->e(Config::get('ext.Scribble.dir.data')); ?></code>
	</p>
	<form method="post" action="<?php $this->html->eUrl(UrlCommand::createUrl('scribble', 'install')); ?>">

		<dl>
			<dt>Enter an email address for the main administrator of this system</dt>
			<dd><input type="text" name="email" value="" />
		<input type="submit" name="go" value="Install Now" /></dd>
		</dl>

	</form>
<?php endif; ?>
